<?php

namespace app\model;

use think\Model;

class PublicCollect extends Model
{
    /**
     * 公示栏收藏表
     */
    protected $createTime='create_date';

    //添加收藏内容
    public function addData($data)
    {
        return self::create($data);
    }

    //删除收藏
    public function delData($data): bool
    {
        return $this->where(['order_person_id'=>$data['order_person_id'],'type'=>$data['type'],'uid'=>$data['uid']])->delete ();
    }

    //查询收藏
    public function getOrderPersonIdData($id):bool
    {
        return (bool)$this->where (['order_person_id'=>$id])->select()->toArray ();
    }

    /**
     * 查询id是否被收藏
     * @param $id
     * @return \app\model\PublicCollect|array|mixed|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getIdCollectModel($id)
    {
        return $this->where (['order_person_id'=>$id])->find();
    }


}